Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opencode-cli-auth

Detect the agent CLIs installed on your machine and reuse the logins they already hold, so you don't sign in to the same providers twice.

Ships two things:

  • A plugin that reports which CLIs are installed and signed in, and imports their credentials into OpenCode.
  • opencode-provider-claude-code — a provider that runs the local Claude Code CLI, so claude-code/* models appear in /models.

Supported CLIs

CLI id Importable into
Claude Code claude
Codex codex openai
Gemini CLI gemini google
Antigravity antigravity
Qwen Code qwen
Cursor Agent cursor-agent
GitHub Copilot CLI copilot
OpenCode opencode

Claude Code also resolves through the openclaude fork. CLIs without an import target keep their credential somewhere unreadable (the OS keyring) or have no matching OpenCode provider — their sign-in state is still reported.

Each CLI honours a <NAME>_BIN environment variable pointing at an absolute path: CLAUDE_BIN, CODEX_BIN, GEMINI_BIN, AGY_BIN, QWEN_BIN, CURSOR_AGENT_BIN, COPILOT_BIN, OPENCODE_BIN.

Install

OpenCode loads flat .ts files from its plugins directory, so the install is a clone plus a one-line entry file.

Option A — one command

git clone https://github.com/shadowraven69/opencode-cli-auth.git ~/opencode-cli-auth && \
mkdir -p ~/.config/opencode/plugins && \
echo 'export * from "../../../opencode-cli-auth/src/index.ts"' > ~/.config/opencode/plugins/cli-auth.ts

The relative path works the same on Linux, macOS, and Windows. Clone elsewhere if you like — just keep the entry file pointing at src/index.ts inside the clone.

Option B — ask your agent

Install the opencode-cli-auth plugin into OpenCode for me.

  1. Clone https://github.com/shadowraven69/opencode-cli-auth to ~/opencode-cli-auth.
  2. OpenCode only loads FLAT .ts files from its plugins directory — a folder with an index.ts is ignored — so create ~/.config/opencode/plugins/cli-auth.ts containing exactly one line: export * from "../../../opencode-cli-auth/src/index.ts"
  3. Do not overwrite that file if it already exists; show it to me instead.
  4. Verify with opencode models > /dev/null && echo ok.

Do not add anything to my opencode.json; this plugin needs no config.

Confirm

opencode models > /dev/null && echo ok

Use

Two tools, callable by the agent.

cli_auth_status — which CLIs are installed, where, whether each is signed in, and which logins can be imported.

Argument Type Purpose
only string[] Restrict the scan to specific CLI ids
includeSearchPath boolean List every directory that was searched

cli_auth_import — copy one CLI's login into OpenCode.

Argument Type Purpose
cli string CLI id to import from

Importing replaces whatever credential that provider currently holds. Run cli_auth_status first.

From a terminal, without involving OpenCode:

node --experimental-strip-types scripts/smoke.ts

Troubleshooting

Installed but reported not-on-path — run cli_auth_status with includeSearchPath: true, then pin it: export CODEX_BIN="/abs/path/to/codex".

Reported shim-broken — the wrapper resolved but its target is gone, usually a leftover shim from an uninstalled version. Reinstall, or pin <NAME>_BIN.

auth=unknown for Gemini or Qwen — expected. Neither exposes a safe status command, so state is inferred from their credential file. Sign in once and it appears.

Tools don't show up — the module failed to load. Check with opencode models > /dev/null && echo ok.

License

MIT

About

Detect local agent CLIs (Claude Code, Codex, Gemini, Antigravity...) in OpenCode, reuse their logins, and run Claude Code as a provider.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages